const searchKeyInObj = ({ value, obj }) => {
  let targetKey = ''
  Object.keys(obj).forEach(key => {
    if (!targetKey && obj[key] === value) {
      targetKey = key
    }
  })

  return targetKey
}

const config = {
  MAGIC: {
    questionType: {
      '单选题': 1,
      '多选题': 2,
      '判断题': 3
    },
    labelTest: {
      'title': /[题目][题干]/,
      'optionA': /A/i,
      'optionB': /B/i,
      'optionC': /C/i,
      'optionD': /D/i,
      'optionE': /E/i,
      'optionF': /F/i,
      'correct': /答案/,
      'remarks': /备注/
    }
  },

  MAPS: {
    questionType: type => {
      return searchKeyInObj({
        value: type,
        obj: config.MAGIC.questionType
      })
    }
  }
}

export default config
